package com.aaa.hospital.ManagementEnd.service.Impl;

import com.aaa.hospital.ManagementEnd.mapper.ResetPasswordDao;
import com.aaa.hospital.ManagementEnd.pojo.Docuser;
import com.aaa.hospital.ManagementEnd.pojo.Nurse;
import com.aaa.hospital.ManagementEnd.pojo.User;
import com.aaa.hospital.ManagementEnd.service.ResetPasswordService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class ResetPasswordServiceImpl implements ResetPasswordService {

    @Autowired
    private ResetPasswordDao passwordDao;


    @Override
    public boolean verification(Integer uid, String idcard) {
        User user = passwordDao.user_find(uid, idcard);
      if(user==null){
          Docuser docuse = passwordDao.docuse_find(uid, idcard);
          if (docuse == null) {
              Nurse nurse =   passwordDao.nurse_find(uid, idcard);
              if (nurse == null) {
                  return false;
              }
              return true;
          }
      }
        return true;
    }

    @Override
    public boolean reset_password(Integer uid, String idcard,String password) {
        boolean user = passwordDao.user_reset(uid, idcard, password);
        if (user == false) {
            boolean docuse = passwordDao.docuse_reset(uid, idcard, password);
            if (docuse == false) {
               return passwordDao.nurse_reset(uid, idcard, password);
            }else {
            return true;}
        }

        return true;
    }
}
